package com.ybwh.datasource.refreshable.druid.spring.boot;

import org.springframework.context.annotation.Condition;
import org.springframework.context.annotation.ConditionContext;
import org.springframework.core.type.AnnotatedTypeMetadata;
import org.springframework.util.StringUtils;

/**
 * <p>
 * spring boot 自动生效的条件
 * </p>
 *
 * @author fanbeibei
 * @version V1.0
 * @since 2019/4/8 18:28
 */
public class SpringBootRefreshDruidCondition implements Condition {
    @Override
    public boolean matches(ConditionContext context, AnnotatedTypeMetadata metadata) {
        String url = context.getEnvironment().getProperty("refreshable.datasource.druid.url");
        if (StringUtils.hasText(url)) {
            return true;
        }

        return false;
    }
}
